#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
    vector<set<string>> a(26);
    vector<set<string>> b(26);
    string s;
    while (getline(cin, s))
    {
        if (s.find(' ') == string::npos)
        {
            if (s[0] >= 'a' && s[0] <= 'z')
                a[s[0] - 'a'].insert(s);
            else a[s[0] + 32 - 'a'].insert(s);
        }
        else
        {
            if (s[0] >= 'a' && s[0] <= 'z')
                b[s[0] - 'a'].insert(s);
            else b[s[0] + 32 - 'a'].insert(s);
        }
    }
    for (int i = 0; i < 26; i++)
    {
        if (a[i].empty() && b[i].empty()) continue;
        int sz = a[i].size() + b[i].size();
        cout << (char)('A' + i) << ' ' << sz << endl;
        for (auto& e : a[i]) cout << e << endl;
        for (auto& e : b[i]) cout << e << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}